<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Peach-Editor 编辑器</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="jquery.min.js"></script>
    <style>
        .editor-form .input-check {
            margin: 0;
            margin-left: 4px;
        }
    </style>
</head>

<body>
    <div class="editor-form">
        <table class="layout-table" style="margin: 10px 20px;">
            <tr>
                <td class="table-input" colspan="2">
                    <input type="checkbox" class="input-check" id="form-fetal-field1">
                    <label for="form-fetal-field1">肚脐左上方</label>
                </td>
                <td class="table-input" colspan="2">
                    <input type="checkbox" class="input-check" id="form-fetal-field2">
                    <label for="form-fetal-field2">肚脐右上方</label>
                </td>
            </tr>
            <tr>
                <td class="table-input" colspan="2">
                    <input type="checkbox" class="input-check" id="form-fetal-field3">
                    <label for="form-fetal-field3">腹壁左方</label>
                </td>
                <td class="table-input" colspan="2">
                    <input type="checkbox" class="input-check" id="form-fetal-field4">
                    <label for="form-fetal-field4">腹壁右方</label>
                </td>
            </tr>
            <tr>
                <td class="table-input" colspan="2">
                    <input type="checkbox" class="input-check" id="form-fetal-field5">
                    <label for="form-fetal-field5">肚脐左下方</label>
                </td>
                <td class="table-input" colspan="2">
                    <input type="checkbox" class="input-check" id="form-fetal-field6">
                    <label for="form-fetal-field6">肚脐右下方</label>
                </td>
            </tr>
        </table>
    </div>
    <script>
        let componentInfo = {}
        function render(baseInfo, newinfo) {
            componentInfo = Object.assign(baseInfo, newinfo);
            "123456".split("").forEach(c => {
                tools.renderCheck(`#form-fetal-field${c}`, componentInfo[`field${c}`], (val) => {
                    componentInfo[`field${c}`] = val
                })
            })
        }

        function getComponentInfo() {
            return componentInfo
        }

        const tools = {
            renderCheck: function (elem, value, callback) {
                $(elem).each(function () {
                    $(this).prop("checked", value)
                })
                $(elem).click(function () {
                    callback($(this).prop('checked'));
                });
            },
        }


    </script>
</body>

</html>